﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

using Framework.Graphics;
using Framework.Graphics.Light;
using Framework.GameStateManagment;
using Framework.GameObjectManagment;
using Framework.GameObjectManagment.GameObjects;

namespace Framework.GameObjectManagment.GameObjects
{
    class Enemy:GameObject
    {
        int _life;
        Texture2D _back, _front;
        Vector2 _position, _target;

        public Vector2 Target
        {
            get { return _target; }
            set { _target = value; }
        }

        public override void Init()
        {
            base.Init();

            _position = new Vector2(100, 100); // default position
            _life = 100; // default lifes
        }

        public override void LoadContent(ContentManager content)
        {
            _back = content.Load<Texture2D>(@"GameObject/Enemy/Enemy1-Ground");
            _front = content.Load<Texture2D>(@"GameObject/Enemy/Enemy1-Body");

            base.LoadContent(content);
        }

        public override void Update()
        {
            _position = new Vector2(100, 300); // test
            base.Update();
        }

        public override void Draw()
        {
            base.Draw();

            float rotation = (float)Math.Atan2(_target.Y - (_position.Y + Input.Movement.Y), _target.X - (_position.X + Input.Movement.X));
            //float rotation = 0;


            Camera.TryDraw(_back, _position, null, Color.White, 0f, Vector2.Zero, 0.5f, SpriteEffects.None, 0f);
            Camera.TryDraw(_front, _position, null, Color.White, 0f, Vector2.Zero, 0.5f, SpriteEffects.None, 0f);
            //Camera.TryDraw(_front, _position, null, Color.White, rotation, new Vector2(-75,-75)
            //    , 0.5f, SpriteEffects.None, 0f);
        }

        public override void DrawShadows(LightArea LA)
        {
            Camera.TryDraw(_back, LA.ToRelativePosition(_position), null, Color.White, 0f, Vector2.Zero, 0.5f, SpriteEffects.None, 0f);
            base.DrawShadows(LA);
        }
    }
}
